﻿namespace PathologyDAL.Modle
{
    public class QueryItem
    {
        private bool needCalculate;

        private FilterCondition? cellMorphology;
        private FilterCondition? bloodVessel;
        private FilterCondition? organizationalStructure;
        private FilterCondition? interstitium;
        private FilterCondition? immunohistochemistry;

        /// <summary>
        /// 细胞形态
        /// </summary>
        public FilterCondition? CellMorphology
        {
            get { return cellMorphology; }
            set
            {
                if (cellMorphology == null)
                {
                    if (value != null)
                    {
                        cellMorphology = value;
                        needCalculate = true;
                    }
                }
                else
                {
                    if (value == null)
                    {
                        cellMorphology = value;
                        needCalculate = true;
                    }
                    else
                    {
                        if (value.Id != cellMorphology.Id)
                        {
                            needCalculate = true;
                        }
                        cellMorphology = value;
                    }
                }
            }
        }

        public bool CellMorphologyQuery
        {
            get { return cellMorphology != null; }
        }

        /// <summary>
        /// 血管
        /// </summary>
        public FilterCondition? BloodVessel
        {
            get { return bloodVessel; }
            set
            {
                if (bloodVessel == null)
                {
                    if (value != null)
                    {
                        bloodVessel = value;
                        needCalculate = true;
                    }
                }
                else
                {
                    if (value == null)
                    {
                        bloodVessel = value;
                        needCalculate = true;
                    }
                    else
                    {
                        if (value.Id != bloodVessel.Id)
                        {
                            needCalculate = true;
                        }
                        bloodVessel = value;
                    }
                }
            }
        }

        public bool BloodVesselQuery
        {
            get { return bloodVessel != null; }
        }

        /// <summary>
        /// 免疫组化
        /// </summary>
        public FilterCondition? Immunohistochemistry
        {
            get { return immunohistochemistry; }
            set
            {
                if (immunohistochemistry == null)
                {
                    if (value != null)
                    {
                        immunohistochemistry = value;
                        needCalculate = true;
                    }
                }
                else
                {
                    if (value == null)
                    {
                        immunohistochemistry = value;
                        needCalculate = true;
                    }
                    else
                    {
                        if (value.Id != immunohistochemistry.Id)
                        {
                            needCalculate = true;
                        }
                        immunohistochemistry = value;
                    }
                }
            }
        }

        public bool ImmunohistochemistryQuery
        {
            get { return immunohistochemistry != null; }
        }

        /// <summary>
        /// 间质
        /// </summary>
        public FilterCondition? Interstitium
        {
            get { return interstitium; }
            set
            {
                if (interstitium == null)
                {
                    if (value != null)
                    {
                        interstitium = value;
                        needCalculate = true;
                    }
                }
                else
                {
                    if (value == null)
                    {
                        interstitium = value;
                        needCalculate = true;
                    }
                    else
                    {
                        if (value.Id != interstitium.Id)
                        {
                            needCalculate = true;
                        }
                        interstitium = value;
                    }
                }
            }
        }

        public bool InterstitiumQuery
        {
            get { return interstitium != null; }
        }

        /// <summary>
        /// 组织学结构
        /// </summary>
        public FilterCondition? OrganizationalStructure
        {
            get { return organizationalStructure; }
            set
            {
                if (organizationalStructure == null)
                {
                    if (value != null)
                    {
                        organizationalStructure = value;
                        needCalculate = true;
                    }
                }
                else
                {
                    if (value == null)
                    {
                        organizationalStructure = value;
                        needCalculate = true;
                    }
                    else
                    {
                        if (value.Id != organizationalStructure.Id)
                        {
                            needCalculate = true;
                        }
                        organizationalStructure = value;
                    }
                }
            }
        }

        public bool OrganizationalStructureQuery
        {
            get { return organizationalStructure != null; }
        }

        /// <summary>
        /// 查询条件是否发生了改变
        /// </summary>
        public bool NeedCalculate { get { return needCalculate; } }

        public void CalculateSuccess()
        {
            needCalculate = false;
        }
    }
}
